import {
  wxRequest
} from '../../../utils/server.js';
const _wxRequest = new wxRequest();
const app = getApp()
Page({
  data: {
    imgUrl: app.globalData.imgUrl,
    uploadUrl: wx.getStorageSync('uploadUrl'),
    pageNo: 1,
    hasNextPage: false,
    list: [],
    keyword: '',
    sharedType: ''
  },

  onLoad(options) {
    console.log(options, 'options')
    if (options.id) {
      this.setData({
        id: options.id,
        sharedType: options.sharedType
      })
    }
  },

  onShow: function () {
    this.getlist()
  },

  //查询列表
  getlist: function () {
    let url = '/odr/protected/settle/myListDetail?setId=' + this.data.id + '&pageNo=' + this.data.pageNo + '&pageSize=10'
    _wxRequest.wxTonkenAjax({
      url: app.globalData.apiUrl + url,
      method: 'POST'
    }, (res) => {
      console.log(res);
      let list = res.list;
      if (this.data.pageNo !== 1) {
        list = this.data.list.concat(list);
      }

      console.log(list, 'list')

      this.setData({
        list: list,
        pageNo: res.page.pageNo,
        hasNextPage: res.page.hasNextPage,
      });


    })
  },


  //下拉刷新
  onPullDownRefresh: function () {
    this.refreshData();
    wx.stopPullDownRefresh()
  },

  refreshData: function () {
    this.setData({
      pageNo: 1
    })
    this.getlist();
  },

  //触底时，加载更多
  onReachBottom: function () {
    if (this.data.hasNextPage) {
      this.setData({
        pageNo: this.data.pageNo + 1
      });
      this.getlist();
    }
  },
  toDtail: function (e) {
    var id = e.currentTarget.dataset.id;
    console.log(id, 'id')
    wx.navigateTo({
      url: '/pages/menber/mall/detail?id=' + e.currentTarget.dataset.id + "&typefg=1",
    })
  }

})